const router = require('koa-router')()

router.get('/', async (ctx, next) => {
  await ctx.render('index', {
    title: 'Hello Koa 2!'
  })
})

router.get('/string', async (ctx, next) => {
  ctx.body = 'koa2 string'
})

router.get('/json', async (ctx, next) => {
  console.log(ctx);
  ctx.response.stuats = 200
  ctx.body = {
    title: 'koa2 json'
  }
})

router.get('/h5_headNavList', async (ctx, next) => {
  let {test} = ctx.request.query;
  console.log(test);
  ctx.response.stuats = 200
  ctx.response.body = {
    result: {
      data: [
        {
          id: 1,
          value: "吵吵"
        },
        {
          id: 2,
          value: "吵吵"
        },
        {
          id: 3,
          value: "吵吵"
        },
        {
          id: 4,
          value: "吵吵"
        },
        {
          id: 5,
          value: "吵吵"
        },
        {
          id: 6,
          value: "吵吵"
        },
        {
          id: 7,
          value: "吵"
        },
        {
          id: 8,
          value: "吵"
        }
      ]
    },
    message: '查询成功',
    code: 1
  }

})

module.exports = router
